<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/11/10
  Time: 9:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="${pageContext.request.contextPath}/assets/images/favicon.png" type="image/png">
    <title>商品列表</title>

    <link href="${pageContext.request.contextPath}/assets/plugins/morris-chart/morris.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet"/>
    <link href="${pageContext.request.contextPath}/assets/css/icons.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/css/responsive.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/assets/css/icons/font-awesome/font-awesome.css">
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        .el-table__row {
            height: 200px;
        }

        .main-content {
            background-color: white;
        }

        tr td a {
            margin-right: 10px;
        }

        .container .table thead tr th {
            line-height: 60px;
            text-align: center;
        }

        /*.btn {*/
        /*    border-radius: 5px;*/
        /*}*/

        .container .table tbody tr td {
            line-height: 30px;
            height: 90px;
        }

        .container .table tbody tr td div {
            line-height: 30px;
            height: 90px;
        }

        i, button {
            cursor: pointer;
        }

        #wd {
            display: none;
            position: relative;
            top: -130%;
            background-color: rgba(245, 245, 245, 0);
            z-index: 5;
        }

        #wd #openWindow {
            position: fixed;
            margin: auto;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            overflow: hidden;
            width: 600px;
            height: 400px;
            border: 1px solid #666;
            border-radius: 15px;
            background-color: rgba(245, 245, 245, 1);
            z-index: 5;
            box-shadow: 1px 1px 22px #CCCCCC;
        }

        #wd .title {
            position: relative;
            width: 100%;
            height: 30px;
            border-bottom: 1px solid #666;
            z-index: 5;
        }
        #page {
            text-align: center;
            width: 34px;
            height: 34px;

        }

        #select_pageSize {
            width: 110px;
            height: 34px;
        }

        #wd .bottom {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 40px;
            border-top: 1px solid #666;
            z-index: 5;
        }

        #wd .bottom .bottomBtn {
            position: absolute;
            top: 0;
            right: 0;
            margin-top: 5px;
            width: 200px;
            height: 30px;
            z-index: 5;
        }

        #wd .bottom button {
            margin-right: 20px;
            width: 60px;
            height: 30px;
            border: none;
            color: #fff;
            border-radius: 5px;
            z-index: 5;
        }

        #cancel {
            background-color: red;
            z-index: 5;
        }

        #confirm {
            background-color: skyblue;
            z-index: 5;
        }
        .toPage{
            outline: #0e90d2;

        }
        .page-item input{
            border-left: none;
            border-right: none;
            border-top:1px solid #c0c0c0;
            border-top-width: 1px;
            border-bottom-width: 1px;
            border-color: #c0c4cc;
        }
        .page-item select{
            border-left: none;
            border-right: none;
            border-top:1px solid #c0c0c0;
            border-top-width: 1px;
            border-bottom-width: 1px;
            border-color: #c0c4cc;
        }
        input:focus {

            outline: #0e90d2;
        }
    </style>
</head>
<body>
<div class="main-content">
    <jsp:include page="../inc/left.jsp"/>
    <div class="header-section">

        <a class="toggle-btn"><i class="fa fa-bars"></i></a>

        <form class="searchform">
            <input type="text" class="form-control" name="keyword" placeholder="Search here..."/>
        </form>

        <!--notification menu start -->
        <div class="menu-right">
            <ul class="notification-menu">
                <li>
                    <a href="#" class="btn btn-default dropdown-toggle info-number" data-toggle="dropdown">
                        <i class="fa fa-tasks"></i>
                        <span class="badge">8</span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-head pull-right">
                        <h5 class="title">You have 8 pending task</h5>
                        <ul class="dropdown-list">
                            <li class="notification-scroll-list notification-list ">
                                <!-- list item-->
                                <a href="javascript:void(0);" class="list-group-item">
                                    <div class="media">
                                        <div class="pull-left p-r-10">
                                            <em class="fa  fa-shopping-cart noti-primary"></em>
                                        </div>
                                        <div class="media-body">
                                            <h5 class="media-heading">A new order has been placed.</h5>
                                            <p class="m-0">
                                                <small>29 min ago</small>
                                            </p>
                                        </div>
                                    </div>
                                </a>

                                <!-- list item-->
                                <a href="javascript:void(0);" class="list-group-item">
                                    <div class="media">
                                        <div class="pull-left p-r-10">
                                            <em class="fa fa-check noti-success"></em>
                                        </div>
                                        <div class="media-body">
                                            <h5 class="media-heading">Databse backup is complete</h5>
                                            <p class="m-0">
                                                <small>12 min ago</small>
                                            </p>
                                        </div>
                                    </div>
                                </a>

                                <!-- list item-->
                                <a href="javascript:void(0);" class="list-group-item">
                                    <div class="media">
                                        <div class="pull-left p-r-10">
                                            <em class="fa fa-user-plus noti-info"></em>
                                        </div>
                                        <div class="media-body">
                                            <h5 class="media-heading">New user registered</h5>
                                            <p class="m-0">
                                                <small>17 min ago</small>
                                            </p>
                                        </div>
                                    </div>
                                </a>

                                <!-- list item-->
                                <a href="javascript:void(0);" class="list-group-item">
                                    <div class="media">
                                        <div class="pull-left p-r-10">
                                            <em class="fa fa-diamond noti-danger"></em>
                                        </div>
                                        <div class="media-body">
                                            <h5 class="media-heading">Database error.</h5>
                                            <p class="m-0">
                                                <small>11 min ago</small>
                                            </p>
                                        </div>
                                    </div>
                                </a>

                                <!-- list item-->
                                <a href="javascript:void(0);" class="list-group-item">
                                    <div class="media">
                                        <div class="pull-left p-r-10">
                                            <em class="fa fa-cog noti-warning"></em>
                                        </div>
                                        <div class="media-body">
                                            <h5 class="media-heading">New settings</h5>
                                            <p class="m-0">
                                                <small>18 min ago</small>
                                            </p>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <li class="last"><a href="#">View all notifications</a></li>
                        </ul>
                    </div>
                </li>

                <li>
                    <a href="#" class="btn btn-default dropdown-toggle info-number" data-toggle="dropdown">
                        <i class="fa fa-bell-o"></i>
                        <span class="badge">4</span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-head pull-right">
                        <h5 class="title">Notifications</h5>
                        <ul class="dropdown-list normal-list">
                            <li class="message-list message-scroll-list">
                                <a href="#">
                                    <span class="photo"> <img
                                            src="${pageContext.request.contextPath}/assets/images/users/avatar-8.jpg"
                                            class="img-circle" alt="img"></span>
                                    <span class="subject">John Doe</span>
                                    <span class="message"> New tasks needs to be done</span>
                                    <span class="time">15 minutes ago</span>
                                </a>

                                <a href="#">
                                    <span class="photo"> <img
                                            src="${pageContext.request.contextPath}/assets/images/users/avatar-7.jpg"
                                            class="img-circle" alt="img"></span>
                                    <span class="subject">John Doe</span>
                                    <span class="message"> New tasks needs to be done</span>
                                    <span class="time">10 minutes ago</span>
                                </a>

                                <a href="#">
                                    <span class="photo"> <img
                                            src="${pageContext.request.contextPath}/assets/images/users/avatar-6.jpg"
                                            class="img-circle" alt="img"></span>
                                    <span class="subject">John Doe</span>
                                    <span class="message"> New tasks needs to be done</span>
                                    <span class="time">20 minutes ago</span>
                                </a>

                                <a href="#">
                                    <span class="photo"> <img
                                            src="${pageContext.request.contextPath}/assets/images/users/avatar-6.jpg"
                                            class="img-circle" alt="img"></span>
                                    <span class="subject">John Doe</span>
                                    <span class="message"> New tasks needs to be done</span>
                                    <span class="time">20 minutes ago</span>
                                </a>

                                <a href="#">
                                    <span class="photo"> <img
                                            src="${pageContext.request.contextPath}/assets/images/users/avatar-6.jpg"
                                            class="img-circle" alt="img"></span>
                                    <span class="subject">John Doe</span>
                                    <span class="message"> New tasks needs to be done</span>
                                    <span class="time">20 minutes ago</span>
                                </a>

                                <a href="#">
                                    <span class="photo"> <img
                                            src="${pageContext.request.contextPath}/assets/images/users/avatar-6.jpg"
                                            class="img-circle" alt="img"></span>
                                    <span class="subject">John Doe</span>
                                    <span class="message"> New tasks needs to be done</span>
                                    <span class="time">20 minutes ago</span>
                                </a>
                            </li>
                            <li class="last"><a href="#">All Messages</a></li>
                        </ul>
                    </div>
                </li>
                <li>
                    <a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        <img src="${pageContext.request.contextPath}/assets/images/users/avatar-6.jpg" alt=""/>
                        John Doe
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-usermenu pull-right">
                        <li><a href="#"> <i class="fa fa-wrench"></i> Settings </a></li>
                        <li><a href="#"> <i class="fa fa-user"></i> Profile </a></li>
                        <li><a href="#"> <i class="fa fa-info"></i> Help </a></li>
                        <li><a href="#"> <i class="fa fa-lock"></i> Logout </a></li>
                    </ul>
                </li>

            </ul>
        </div>
        <!--notification menu end -->

    </div>

    <div class="wrapper" style="background-color: #eeeeee;width: 100%">

        <div class="page-title-box" style="background-color: #FFFFFF;">
            <h4 class="page-title">商品列表</h4>(王洪贵)
            <ol class="breadcrumb">
                <li>
                    <a href="${pageContext.request.contextPath}/index">首页</a>
                </li>
                <li>
                    <a href="productList">商品</a>
                </li>
                <li class="active">
                    商品列表
                </li>
            </ol>
            <div class="clearfix"></div>
        </div>

        <div class="container"
             style="margin-top: 20px;margin-bottom: 0px;  border:solid 1px rgba(0,0,0,0.2);padding: 20px;background-color: #FFFFFF;">
            筛选搜索


            <form action="findProductList" style="margin-top: 10px;text-indent: 2em" class="form-inline" method="post">
                <label for="input1">输入搜索: </label>
                <input class="form-control" id="input1" placeholder="商品名称" name="name" value="${product.name}" size="19">
                <label for="input2">商品货号: </label>
                <input id="input2" type="text" placeholder="商品货号" class="form-control" name="productSn" size="19"
                       style="cursor: pointer" value="${product.productSn}">
                &emsp;&emsp;
                <span>商品分类:</span>
                <select class="form-control" style="width: 180px" name="productCategoryId">
                    <option value="">全部</option>
                    <c:forEach items="${category}" var="ct">
                        <option value="${ct.id}" ${product.productCategoryId==ct.id?"selected":""}>${ct.name}</option>
                    </c:forEach>
                </select>
                <div style="display: inline-block;margin-left: 20px;margin-top: 20px">
                    <span>商品品牌:</span>
                    <select class="form-control" style="width: 180px" name="brandId">
                        <option value="">全部</option>
                        <c:forEach items="${brands}" var="b">
                            <option value="${b.id}" ${product.brandId==b.id?"selected":""}>${b.name}</option>
                        </c:forEach>
                    </select>
                </div>

                <div style="display: inline-block;margin-left: 27px;margin-top: 20px">
                    <span>上架状态:</span>
                    <select class="form-control" style="width: 180px" name="publishStatus">
                        <option value="">全部</option>
                        <option value="1" ${product.publishStatus==1?"selected":""}>上架</option>
                        <option value="0" ${product.publishStatus==0?"selected":""}>下架</option>
                    </select>
                </div>
                <div style="display: inline-block;margin-left: 4px;margin-top: 20px">
                    <span>审核状态:</span>
                    <select class="form-control" style="width: 180px" name="verifyStatus">
                        <option selected value="">全部</option>
                        <option value="1" ${product.verifyStatus==1?"selected":""}>审核通过</option>
                        <option value="0" ${product.verifyStatus==0?"selected":""}>未审核</option>
                    </select>
                </div>
                <a href="setNull" class="btn btn-default"
                   style="float: right;margin-top: -90px;margin-right: 100px;text-align: center;padding: 6px 24px 6px 0px">重置</a>
                <button type="submit" class="btn btn-primary" style="float: right;margin-left: 5px;margin-top: -90px">
                    查询结果
                </button>
            </form>
        </div>

        <div class="container"
             style="margin-top: 20px;margin-bottom: 20px;  border:solid 1px rgba(0,0,0,0.2);padding: 20px;background-color: #FFFFFF">
            <div class="el-card__body"><i class="fa fa-bar-chart-o"></i> <span>数据列表</span>
                <a type="button" href="productAdd" class="btn btn-primary" style="float: right">
                    <span>添加</span>
                </a>
            </div>
        </div>


        <div class="container" style="background-color: #FFFFFF">
            <table class="table table-hover" style="font-size: 15px;width: 100%">
                <thead>
                <tr>
                    <th></th>
                    <th>编号</th>
                    <th>商品图片</th>
                    <th>商品名称</th>
                    <th>价格/货号</th>
                    <th>标签</th>
                    <th>排序</th>
                    <th>SKU库存</th>
                    <th>销量</th>
                    <th>审核状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody style="text-align: center">
                <c:forEach items="${pageInfo.list}" var="p">
                    <tr>
                        <td>
                            <input type="checkbox" aria-hidden="true" value="" style="margin-top: 40px">
                        </td>
                        <td style="line-height: 90px;">
                            <div style="line-height: 90px;">${p.id}</div>
                        </td>
                        <td class="el-table_1_column_3 is-center ">
                            <div style="line-height: 90px;"><img
                                    src="${p.pic}"
                                    style="height: 80px;"></div>
                        </td>
                        <td style="width: 300px;line-height: 90px;">
                            <p style="line-height: 45px;overflow: hidden;height: 45px;text-overflow: '...'">名称:${p.name}</p>
                            <p style="line-height: 50px;overflow: hidden;height: 50px;text-overflow: '...'">品牌:${p.brandName}</p>
                        </td>
                        <td>
                            <div><p style="line-height: 45px">价格：￥${p.price}</p>
                                <p style="line-height: 45px">货号：${p.productSn}</p></div>
                        </td>
                        <td>
                            <div class="cell"><p style="margin: 0px;padding: 0px">上架：
                                <a>
                                    <i class="fa fa-2x fa-toggle-${p.publishStatus==1?'on':'off'}" publish="${p.publishStatus}" pid="${p.id}" onclick="sw(this)"></i>
                                </a>
                            </p>
                                <p style="margin: 0px;padding: 0px">新品：
                                    <a>
                                        <i class="fa fa-2x fa-toggle-${p.newStatus==1?'on':'off'}" new="${p.newStatus}" pid="${p.id}" onclick="sw(this)"></i>
                                    </a>
                                </p>
                                <p style="margin: 0px;padding: 0px">推荐：
                                    <a>
                                        <i class="fa fa-2x fa-toggle-${p.recommandStatus==1?'on':'off'}" recommand="${p.recommandStatus}" pid="${p.id}" onclick="sw(this)"></i>
                                    </a>
                                </p>
                            </div>
                        </td>
                        <td>
                            <div style="line-height: 90px;">${p.sort}</div>
                        </td>
                        <td>
                            <div style="line-height: 90px;">
                                <a type="button" class="btn btn-info round" onclick="btn(this)" pid="${p.id}" style="margin-top: 32px">
                                    <i class="fa fa-edit"></i></a>
                            </div>
                        </td>
                        <td>
                            <div style="line-height: 90px;">${p.sale}</div>
                        </td>
                        <td>
                            <div  style="line-height: 90px;"><p>${p.verifyStatus==1?"审核通过":"未审核"}</p>
                            </div>
                        </td>
                        <td>
                            <div style="line-height: 90px;">
                                <p>
                                    <a type="button" href="detail?id=${p.id}" class="btn btn-info" id="findDetail" style="margin-right: 0px">
                                        <span>查看</span>
                                    </a>
                                    <a type="button" href="productAdd?id=${p.id}" style="margin-right: 0px"
                                       class="btn btn-primary">
                                        <span>编辑</span>
                                    </a>
                                    <a type="button" href="deleteProduct?id=${p.id}" style="margin-right: 0px"
                                       class="btn btn-danger">
                                        <span>删除</span>
                                    </a>
                                </p>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <br>
            <!--分页开始-->
            <nav aria-label="...">
                <ul class="pagination">
                    <span id="current" hidden>${pageInfo.pageNum}</span>
                    <span id="currentLimt" hidden>${pageInfo.pageSize}</span>
                    <li class="page-item disabled" style="border-color:white">
                        <span class="page-link" href="${pageContext.request.contextPath}/#">共${pageInfo.total}条数据</span>
                    </li>
                    <li style="float: left" class="page-item" style="border-color:white">
                        <select id="select_pageSize" name="pageSize" class="selectC">
                            <option value="5" ${pageInfo.pageSize==5?"selected":""}>5条/页</a></option>
                            <option value="10" ${pageInfo.pageSize==10?"selected":""}>10条/页</option>
                            <option value="15" ${pageInfo.pageSize==15?"selected":""}>15条/页</option>
                            <option value="20" ${pageInfo.pageSize==20?"selected":""}>20条/页</option>
                        </select>
                    </li>
                    <c:if test="${pageInfo.pageNum>1}">
                        <li class="page-item ${pageInfo.pageNum==1?"disabled":""}">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/goods/findProductList?pageNum=${pageInfo.prePage}&pageSize=${pageInfo.pageSize}">上一页</a>
                        </li>
                    </c:if>
                    <li class="page-item ${pageInfo.pageNum==1?"active":""}">
                        <a class="page-link"
                           href="${pageContext.request.contextPath}/goods/findProductList?page=1&pageSize=${pageInfo.pageSize}">1</a>
                    </li>

                    <c:if test="${pageInfo.pageNum>2}">
                        <li class="page-item disabled">
                            <a class="page-link" href="#">...</a>
                        </li>
                    </c:if>

                    <c:if test="${pageInfo.pageNum>1&&pageInfo.pageNum<pageInfo.pages}">
                        <li class="page-item ${(pageInfo.pageNum>1&&pageInfo.pageNum<pageInfo.pages)?"active":""}">
                            <span class="page-link">${pageInfo.pageNum}</span>
                        </li>
                    </c:if>

                    <c:if test="${pageInfo.pageNum<pageInfo.pages-1}">
                        <li class="page-item disabled ">
                            <a class="page-link" href="#">...</a>
                        </li>
                    </c:if>

                    <c:if test="${pageInfo.pages>1}">
                        <li class="page-item ${pageInfo.pageNum==pageInfo.pages?"active":""}">
                            <a id="cntpage" class="page-link "
                               href="${pageContext.request.contextPath}/goods/findProductList?pageNum=${pageInfo.pages}&pageSize=${pageInfo.pageSize}">${pageInfo.pages}</a>
                        </li>
                    </c:if>
                    <c:if test="${pageInfo.pageNum lt pageInfo.pages}">
                        <li class="page-item ${pageInfo.isLastPage?"disabled":""} ">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/goods/findProductList?pageNum=${pageInfo.nextPage}&pageSize=${pageInfo.pageSize}">下一页</a>
                        </li>
                    </c:if>

                    <li class="page-item">
                        <span class="disabled">前往</span>
                        <input id="page" type="text" class="toPage" style="float:left;" name="pageNum" value="${param.pageNum==0 or param.pageNum==""?1:param.pageNum}">
                        <span class="disabled">页</span>
                    </li>

                </ul>
            </nav>
        </div>

    </div>


</div>
<div id="wd">
    <div id="openWindow">
        <h3 style="position:absolute;left: 20px">商品库存信息</h3>
        <i id="closeWindow_tr"></i>
        <br>
        <br>
        <br>
        <br>
        <div>&emsp;<span style="font-size: 12px">商品ID：</span>
            <span style="font-size: 12px" id="code"></span>&emsp;
            <input type="text" autocomplete="off" placeholder="按sku编号搜索" class="el-input__inner"><button style="padding: 4px;margin: 0px;border-left: 0px;border-color: darkgrey"><i class="fa fa-search"></i></button>
        </div>
        <table class="table table-bordered" style="margin-top: 5px">
            <thead>
            <tr>
                <th>SKU编号</th>
                <th>销售价格</th>
                <th>商品库存</th>
                <th>库存预警</th>
            </tr>
            </thead>
            <tbody id="bx_msg_body">
            </tbody>
        </table>
        <div class="bottom">
            <div class="bottomBtn">
                <button id="cancel">取消</button>
                <button id="confirm">确认</button>
            </div>
        </div>
    </div>
</div>
</div>

<!--Begin core plugin -->
<script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/plugins/moment/moment.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/jquery.slimscroll.js "></script>
<script src="${pageContext.request.contextPath}/assets/js/jquery.nicescroll.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/functions.js"></script>
<!-- End core plugin -->

<!--Begin Page Level Plugin-->
<script src="${pageContext.request.contextPath}/assets/plugins/morris-chart/morris.js"></script>
<script src="${pageContext.request.contextPath}/assets/plugins/morris-chart/raphael-min.js"></script>
<script src="${pageContext.request.contextPath}/assets/plugins/jquery-sparkline/jquery.charts-sparkline.js"></script>
<script src="${pageContext.request.contextPath}/assets/pages/dashboard.js"></script>
<!--End Page Level Plugin-->
<script>
    function check(obj){
        var sta=obj.getAttribute("sta")
        if (sta==1){
            confirm("审核人:xxx      审核状态:审核通过")
        }else {
            confirm("审核人:xxx      审核状态:未审核")
        }
    }
    $("#log").click(function () {
        confirm("未完善")
    })
    // 获取打开窗口的按钮
    // let open_wd = document.getElementsByClassName('btn');
    // 获取遮罩层
    let popup_wd = document.getElementById('wd');
    // 右上角关闭按钮
    let i_close = document.getElementById('closeWindow_tr');
    // 取消按钮
    let btn_cancel = document.getElementById('cancel');

    function btn(obj) {
        var pid=obj.getAttribute("pid")
        console.info(pid)
        $.ajax({
            type : 'get',
            url :  "${pageContext.request.contextPath}/goods/alterProduct",
            data : {
                "productId":pid
            },
            success : function(result) {
                var html = '';
                if (result.length==0){
                    html += '<tr>' ;
                    html+='<td><input name="skuCode" size=8></td>';
                    html+='<td><input name="price" size=6></td>';
                    html+='<td><input name="stock" size=6></td>';
                    html+='<td><input name="lowStock" size=6></td>';
                    html+='</tr>';
                }else {
                    for (var i = 0; i < result.length; i++) {
                        console.info(result[i].skuCode);
                        html += '<tr>' ;
                        html+='<td><input value='+ result[i].skuCode+' size=8></td>';
                        html+='<td><input value='+ result[i].price+' size=6></td>';
                        html+='<td><input value='+ result[i].stock+' size=6></td>';
                        html+='<td><input value="" size=6></td>';
                        html+='</tr>';
                    }
                }
                console.info("111")
                $("#code").html(result[0]==null?"没有库存信息":result[0].productId);
                $("#bx_msg_body").html(html);
                console.info("222")
            }
        });
        // $(#wd).setAttribute()
        $("#wd").show(400);
        popup_wd.style.display = 'flex';
    }
    function sw(obj) {
        var publish=obj.getAttribute("publish")
        var news=obj.getAttribute("new")
        var recommand=obj.getAttribute("recommand")
        var pid=obj.getAttribute("pid")
        console.info(pid)
        console.info(publish)
        console.info(news)
        console.info(recommand)
        var sta=null;
        if (publish!=null){
            sta=publish;
        }
        if (news!=null){
            sta=news;
        }
        if (recommand!=null){
            sta=recommand;
        }
        $.ajax({
            type : 'get',
            url :  "${pageContext.request.contextPath}/goods/sw",
            data : {
                "id":pid,
                "publishStatus":sta,
                "newStatus":sta,
                "recommandStatus":sta
            },
            success : function(result) {
                console.info(result)
                if (result!=null){
                    if (publish!=null){
                        obj.setAttribute("class","fa fa-2x fa-toggle-"+(result==1?"on":"off"))
                    }
                    if (news!=null){
                        obj.setAttribute("class","fa fa-2x fa-toggle-"+(result==1?"on":"off"))
                    }
                    if (recommand!=null){
                        obj.setAttribute("class","fa fa-2x fa-toggle-"+(result==1?"on":"off"))
                    }
                }
            }
        });
    }

    i_close.onclick = function () {
        popup_wd.style.display = 'none';
    }
    btn_cancel.onclick = function () {
        popup_wd.style.display = 'none';
    }
    $("#select_pageSize").bind("change",function (){
        let pageSize = $("#select_pageSize").val();
        let pageNum = $("#current").text();
        let name = $("#input1").val();
        let url = $("#input2").val();
        let categoryId = $("#select1").val();
        location.href="${pageContext.request.contextPath}/goods/productList?pageNum="+pageNum+"&pageSize="+pageSize
            +"&name="+name+"&url="+url+"&categoryId="+categoryId;
    })
    $("#page").bind("change",function (){
        let pages = $("#cntpage").text();
        let pageSize = $("#select_pageSize").val();
        let name = $("#input1").val();
        let url = $("#input2").val();
        let categoryId = $("#select1").val();
        let pageNum = $("#page").val();
        console.info(pageNum);
        if(pageNum!=null&&pageNum!=""&&pageNum<=pages){
            location.href="${pageContext.request.contextPath}/goods/"+"${product==null?'productList':'findProductList'}"+"?pageNum="+pageNum+"&pageSize="+pageSize;
        }else{
            layer.open({
                title: "警告！！！",
                content: "不能为空或不能大于总页数！",
                area: ['300px', '160px'],
                offset: ['240px', '680px'],
                yes: function (index, layero) {
                    layer.close(index);
                }
            })
        }
    })
</script>
</body>
</html>
